const TOKEN_KEY = "wblog-user-token";
const USER_KEY = "wblog-user-data";
const ROLE_KEY = "wblog-user-role";
//获取token
export function getToken() {
  return localStorage.getItem(TOKEN_KEY);
}

//保存token
export function setToken(token) {
  return localStorage.setItem(TOKEN_KEY, token);
}

//获取用户信息
export function getUser() {
  return JSON.parse(localStorage.getItem(USER_KEY));
}

//保存用户信息
export function setUser(user) {
  localStorage.setItem(USER_KEY, JSON.stringify(user));
}
//获取角色信息
export function getRole() {
  return localStorage.getItem(ROLE_KEY);
}

//保存角色信息
export function setRole(role) {
  return localStorage.setItem(ROLE_KEY, role);
}
//移除用户信息
export function removeToken() {
  localStorage.removeItem(TOKEN_KEY);
  localStorage.removeItem(USER_KEY);
  localStorage.removeItem(ROLE_KEY);
}
